Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
burtonator opened this issue Jun 22, 2018 · 1 comment

Comments

@burtonator
Copy link

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

@leonardobaggio
Copy link

+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:

  • in order to specify a Service Worker for the mozilla/pdf-js library, a path or blob url should be provided. To create this blob url, we need to get the inline content and convert it (inspired by this gist).
<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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants