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

Move embedded & inline JavaScript and stylesheets to files #4328

Open
dvz opened this issue Mar 20, 2021 · 3 comments
Open

Move embedded & inline JavaScript and stylesheets to files #4328

dvz opened this issue Mar 20, 2021 · 3 comments
Labels
b:1.10 Branch: 1.10.x s:confirmed Status: Confirmed. Retested and found the issue exists t:code-quality Type: Code Quality. Improves code without affecting functionality
Milestone

Comments

@dvz
Copy link
Member

dvz commented Mar 20, 2021

Remove usage of embedded JavaScript <script> and CSS <style> tags and inline on*, style attributes by moving their content to files.

May require a standard of passing and processing server-side data to included front-end scripts.

@dvz dvz added s:confirmed Status: Confirmed. Retested and found the issue exists b:1.10 Branch: 1.10.x t:code-quality Type: Code Quality. Improves code without affecting functionality labels Mar 20, 2021
@dvz dvz added this to the 1.10.0 milestone Mar 20, 2021
@effone
Copy link
Member

effone commented Apr 5, 2021

May require a standard of passing and processing server-side data to included front-end scripts.

Apart from embedding in template I can only think of an AJAX call on runtime.
Or you have a better idea?

@dvz
Copy link
Member Author

dvz commented Apr 5, 2021

We can include raw data using e.g.:

  • <script> JSON blocks (depending on a setting, it may be formatted for readability):

    <script type="application/json" data-json="core">
    {
      "cookieDomain": "",
      "cookiePath": "/forum/",
      "my_post_key": "75170fc230cd88f32e475ff4087f81d9"
    }
    </script>
  • data attributes, accessible to the included script (document.currentScript will help in these cases):

    <script type="text/javascript" src="myPlugin.js" data-json-myplugin='{"uid": 1,"username":"admin"}'></script>
    <script type="text/javascript" src="myPlugin.js" data-uid="1"></script>

and add built-in JS functions to parse it in JavaScript files, e.g. MyBB.data('core'), MyBB.data('myplugin'), MyBB.data('uid').

@dvz dvz changed the title Move inline JavaScript and stylesheets to files Move embedded & inline JavaScript and stylesheets to files Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b:1.10 Branch: 1.10.x s:confirmed Status: Confirmed. Retested and found the issue exists t:code-quality Type: Code Quality. Improves code without affecting functionality
Projects
None yet
Development

No branches or pull requests

3 participants
@dvz @effone and others