remy / inliner

Node utility to inline images, CSS and JavaScript for a web page - useful for mobile sites
MIT License
1.1k stars 165 forks source link

Feature request: Add data-inliner-style-url to <style> for <link rel="stylesheet"> #182

Open burtonator opened 6 years ago

burtonator commented 6 years ago

This way you can track down why what style was sources from which link.

leonardobaggio commented 5 years ago

+1.

This feature would also be useful in many scenarios where the inline contents must be distinguished and selected by another script.

So, thinking in a broader approach, an option to enable the generation of the inline files with a data- attribute, such as data-inliner-name.

From this:

<script>
  <!-- pdf.worker.js content goes here -->
</script>

To this:

<script data-inliner-name="pdf.worker.js">
  <!-- pdf.worker.js content goes here -->
</script>

My example scenario:

<script data-inliner-name="pdf.worker.js">
  <!-- pdf.worker.js content goes here -->
</script>

<script>
  var workerSrc = document.querySelector('[data-inliner-name="pdf.worker.js"]').textContent
  var blob = new Blob([workerSrc], {type: "text/javascript"});
  PDFJS.workerSrc = window.URL.createObjectURL(blob);
</script>

Currently, this task must be done manually, but it seems useful enough to be implemented to this project. :)