A Complete Guide to Bookmarklets | Endigest
CSS-Tricks
|FrontendTags:Articles
bookmarklet
JavaScript
Get the latest tech trends every morning
Receive daily AI-curated summaries of engineering articles from top tech companies worldwide.
This article provides a comprehensive guide to bookmarklets — JavaScript snippets saved as browser bookmarks that can interact with any webpage.
- •Bookmarklets are created by wrapping JavaScript in an IIFE, URL-encoding it, and prefixing with `javascript:` before saving as a browser bookmark
- •CSS can be applied via bookmarklets using `document.createElement('style')` or the more powerful `CSSStyleSheet` interface for direct CSSOM access
- •Content Security Policies (CSP) are the primary limitation, frequently blocking cross-origin requests inside bookmarklets
- •Browser length limits vary: Firefox and Safari cap at 65,536 bytes, while Chrome allows up to ~9,999,999 characters
- •For scripts exceeding limits, alternatives include loading external scripts, userscript tools like TamperMonkey, or building a browser extension
This summary was automatically generated by AI based on the original article and may not be fully accurate.