Bookmarklet to inject an external CSS file into any website

- 1 min read

This bookmarklet provides an easy way to test css styles against a website without access to its server by creating a <link/>element in the <head> of the page. It also updates it with a cache-blocking parameter if already exists.

javascript: (function () {
  let cssLink = document.getElementById('injected-css');
  if (cssLink === null) {
    cssLink = document.createElement('link');
    cssLink.id = 'injected-css';
    cssLink.rel = 'stylesheet';
    document.getElementsByTagName('head')[0].appendChild(cssLink);
  }
  cssLink.href = 'https://albertoroura.com/style.css?v=' + Date.now();
})();

Share: Link copied to clipboard

Tags:

Where: Home > Technical > Bookmarklet to inject an external CSS file into any website