lemonsaurus / django-simple-bulma

Django application to add the Bulma CSS framework and its extensions
MIT License
136 stars 16 forks source link

Defer resource loading #53

Closed JonasUJ closed 4 years ago

JonasUJ commented 4 years ago

This closes #45

I don't know how much of a difference preloading makes, browsers supposedly figure that kind of stuff themselves anyway. I chose defer (over async) for the script tags because that doesn't block the HTML parser. Some of the extensions, like the accordion, also require that you attach them. If we use async, a user who has written a minimal script with only the attach command might get executed before the accordion, and it would fail.

I tested it in a Chromium based browser, IE, and Firefox. All work, but Firefox complains about JS MIME types. However, I suspect this is something to do with how manage.py runserver serves static files.

JonasUJ commented 4 years ago

IIRC I put this in my settings.py and it solved it

if DEBUG:
    import mimetypes
    mimetypes.add_type("text/javascript", ".js", True)