1

I have a Python-based Flask web application that uses Jinja2 to perform templating on the server-side.

I would like to improve my Javascript and CSS loading by using curl.js to load JS and CSS asynchronously.

Is there a specific, well-defined method for doing this?

OOPMan
  • 510
  • 4
  • 8
  • Like any other JS file I guess, what is stopping you adding it in to your base template like you would with a normal – Joe Doherty Jul 29 '14 at 13:17
  • Well, the web application I'm working makes extensive (Probably too extensive, previous devs work) use of the template inheritance, import and include features of Jinja2. Right now this means that the site is a mish-mash of re-used server-side templates that include JavaScript segments along with with the HTML it works on. It's all rather messy and I'm trying to clean it up. – OOPMan Jul 29 '14 at 13:35
  • Well it may be worth re-facotring that. If you want to include some extra JS across the board your going to have this issue regardless. – Joe Doherty Jul 29 '14 at 13:37
  • Ah, so basically what I'm already doing :-) I've added a little extension to our Jinja2 env that allows me to replace – OOPMan Jul 29 '14 at 13:53
  • jQuery [is AMD compatible](http://requirejs.org/docs/jquery.html) – Sean Vieira Jul 29 '14 at 15:32
  • Most popular libs have AMD support built-in. curl.js also supports most CommonJS-formatted modules and global scripts via "loaders". See this document[1] and take a peek at the code comments for more info. [1] https://github.com/cujojs/curl/tree/master/src/curl/loader – unscriptable Jul 29 '14 at 15:59

0 Answers0