A
A
adrenalinruslan2018-03-22 09:31:49
JavaScript
adrenalinruslan, 2018-03-22 09:31:49

Questions about Jquery, JavaScript?

I have a few questions, please help:

1) The user, having opened the source code of the page element, can delete / add / edit the text, page tags, but can he add his own javascript in the script tags that will work? Or can he edit the javascript / jquery code in the script tags so that it works later?

2) How should javascript be loaded?

1* Combine all javascript/jquery codes into one file and include them on every page.

2* Include in script tags only those codes that are needed for this page.

3* Split javascript codes into files and include only the necessary files.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2018-03-22
@sidni

1 since js is a client part, the user can do everything in the browser console after loading and before updating the page.
2 preferably 3* option but you have to look at the circumstances

M
Mikhail Makarov, 2019-02-12
@KevlarBeaver

2.
For speed.
Third-party libraries need to be connected separately and not from your hosting, but from a popular CDN.
It's better to minify your code and link it into one file so that the browser can download it and cache it. If some separate fragments of your code often change (due to the development of the site, for example), then it is better to separate them into a separate file so that the rest of the code, again, is cached.
For reliability.
It is better to place everything on your hosting, which contradicts my previous advice. Because tomorrow, suddenly, access to the CDN may fall off and the site will fall apart.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question