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

Inline js makes it impossible to load form media js in page foot #25

Open
stefanor opened this issue Jan 31, 2018 · 0 comments
Open

Inline js makes it impossible to load form media js in page foot #25

stefanor opened this issue Jan 31, 2018 · 0 comments

Comments

@stefanor
Copy link

For performance, it's usually recommended to render CSS in HTML head and JS in the foot of the page. That way only the CSS loading needs to happen before rendering the page, and the JS can execute once it is visible. (Assuming the page doesn't need the JS to complete to generate content).

Markitup's inline JS requires both jQuery and markitup to be loaded above the widget, in the page.

I would suggest rather having data attributes inline, and adding a single script to the widget's media that consumes these configures the widget.

stefanor added a commit to CTPUG/wafer that referenced this issue Jan 31, 2018
See: zsiciarz/django-markitup#25

django-markitup renders inline JS in each widget that configures the
widget. This JS requires jQuery and markitup.js to already be loaded,
which isn't the case if we're loading JS in the foot of the page.

So, override the template that generates that inline JS, with something
that generates a hidden tag containing only config. Then come back at
the end of the JS loading, and configure the widgets.

I'll do a similar PR upstream and hope that we can pull this out, later.
stefanor added a commit to stefanor/django-markitup that referenced this issue Jan 31, 2018
Rather than using inline scripts like the markitup_editor tag, just
apply some attributes to the widget, so we can locate it later in the
DOM.

This means jQuery doesn't have to be loaded before the MarkItUpWidget is
rendered on a page, all scripts can be loaded in the document foot.

Fixes: zsiciarz#25
stefanor added a commit to stefanor/django-markitup that referenced this issue Feb 1, 2018
Rather than using inline scripts, just apply some attributes to the
widget, so we can locate it later in the DOM.

This means jQuery doesn't have to be loaded before the MarkItUpWidget or
markitup_editor tag is rendered on a page, all scripts can be loaded in
the document foot.

Fixes: zsiciarz#25
stefanor added a commit to stefanor/django-markitup that referenced this issue Mar 26, 2020
Rather than using inline scripts, just apply some attributes to the
widget, so we can locate it later in the DOM.

This means jQuery doesn't have to be loaded before the MarkItUpWidget or
markitup_editor tag is rendered on a page, all scripts can be loaded in
the document foot.

Fixes: zsiciarz#25
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

Successfully merging a pull request may close this issue.

1 participant