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

CSS Lazy Loading #2

Open
Yehonal opened this issue Jun 27, 2016 · 2 comments
Open

CSS Lazy Loading #2

Yehonal opened this issue Jun 27, 2016 · 2 comments

Comments

@Yehonal
Copy link
Contributor

Yehonal commented Jun 27, 2016

Studiare la possibilità di effettuare un lazy loading di files css "legati" ad un controller / componente ( template )

@darioTecchia
Copy link
Contributor

Girovagando per il mondo, con la mia sfera poké ho trovato questo:

<script>
  var cb = function() {
    var l = document.createElement('link'); l.rel = 'stylesheet';
    l.href = 'yourCSSfile.css';
    var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h);
  };
  var raf = requestAnimationFrame || mozRequestAnimationFrame ||
    webkitRequestAnimationFrame || msRequestAnimationFrame;
  if (raf) 
    raf(cb);
  else 
    window.addEventListener('load', cb);
</script>

@Yehonal
Copy link
Contributor Author

Yehonal commented Jun 29, 2016

Si per caricarli è molto semplice, basta creare l'elemento.
Il sistema comunque dovrebbe prevedere di:

  1. caricare un css insieme al template di un componente / controller

  2. rimuovere un css quando quel componente / controller viene rimosso

questo si può fare tramite l'assegnazione di un id univoco per ogni ...però se c'era una soluzione tramite un plugin / tecnica di angular ad esempio sarebbe più comodo :)

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