Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Blob links affects the styles later than JS execution #121

Closed

Description

@ipy

html:

  <style type="text/css">
  .test {
    background: red;
    width: 100px;
    height: 100px;
  }
  </style>
  <div class="test"></div>

css:

.test {
  display: none;
}

js:

require('./test.css');
$('.test').show();

In this case, if css-loader is used with ?sourceMap option, the css will be generated as Blobs. However, it seems that it will take sometime for blob link to load. So $('.test').show(); executes before display: none; takes effect, and nothing shows up.
It's fine to print css directly on the page.

Is there any way to enable source-map without that problem?

Activity

  1. Lihuanghe commented on Jul 16, 2016

    @Lihuanghe
  2. elisechant commented on Sep 8, 2016

    @elisechant

    This is annoying, currently my solution is to do a programmatic setTimeout to delay JavaScript execution which is gross.

    How can we make the style tag blocking, not non-blocking?

    This is my current "workaround":

    if (module.hot) {
      module.hot.accept();
      console.log('Start: delaying JS execution by 4 seconds.');
      setTimeout(() => {
        console.log('Executing.');
        require('./scripts/main');
      }, 4000);
    } else {
      require('./scripts/main');
    }
    

    Stack Overflow referenced here: http://stackoverflow.com/questions/39400038/how-to-ensure-that-hot-css-loads-before-js-in-webpack-dev-server

  3. felipemsantana commented on Feb 13, 2017

    @felipemsantana

    I have this issue too, after doing some research, I found that there was a bug preventing source maps in <style> tag from working, but it's working now for me in Chrome 56.

    Relevant links:
    #30 (comment)
    https://bugs.chromium.org/p/chromium/issues/detail?id=456062

    This probably would fix the relative path in publicUrl with source maps as well.

  4. ekulabuhov commented on Mar 17, 2017

    @ekulabuhov
    Contributor

    There's a planned feature for vNext of the style-loader that will potentially solve this problem. If you're still experiencing this issue could you give it a go and report back on whether it helps? Thank you!

    PR: #165

  5. michael-ciniawsky commented on May 22, 2017

    @michael-ciniawsky
    Contributor

    #219 will fix this, but there is not current timeline when this land, so please be patient :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions