Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Loading order #57

Closed
richburdon opened this issue Aug 9, 2015 · 8 comments
Closed

Loading order #57

richburdon opened this issue Aug 9, 2015 · 8 comments

Comments

@richburdon
Copy link

This might be a more general systemjs feature/question: is it possible to ensure that CSS gets loaded before the main page loads?

I.e., to replace the need for hard coded package links in the header:

<link rel="stylesheet" href="/res/packages/github/twbs/bootstrap@3.3.5/css/bootstrap.css">

With something like this (which works, but loads asynchronously -- so you see the raw HTML for half a second before the CSS loads):

<script type="application/javascript">
  System.import('bootstrap/css/bootstrap.css!');
  System.import('app/test/js/bootstrap.js');
</script>
@guybedford
Copy link
Member

We don't provide guarantees for CSS loading order, just like modules. Although the next major release will actually provide this feature as load execution order is set to be deterministic in the latest loader specification.

@dalgard
Copy link

dalgard commented Jan 8, 2016

@guybedford: When you say 'major release' – are we talking about 1.0.0 of SystemJS? Do you have any idea when that will be?

I need to be able to depend on load order in order to override UI library features without relying on !important statements or inefficient ancestor selectors.

@guybedford
Copy link
Member

@dalgard unfortunately that update won't be anytime soon, as it requires the whatwg loader spec to be stable first.

@dazinator
Copy link

I am experiencing this problem..

Is there some javascript event / method of being notified once all dependencies have been loaded? Because I was thinking of perhaps hiding the entire page content, and then once all dependencies loaded, unhide the content. Does this sound workable?

@dazinator
Copy link

Ok - it was as simple as:

  System.import("js/site").then(function(m) { $('.body').show(); });

@elsasslegend
Copy link

Any updates on this ?

@dazinator
Copy link

dazinator commented Mar 16, 2017

@djflex68 - does System.import("your css").then(function(m) { $('.body').show(); }); not work for you - in combination with the css loader plugin? (with body hidden by default)

@elsasslegend
Copy link

Unfortunately not in my case. I'm trying to load all CSS files of my application using import directive in a single .ts file. Ordering matters because of CSS selectors precedence.

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

No branches or pull requests

5 participants