What impact have JS erros in performance? [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Does anyone if/how to many JS errors affect the server? Does it affect page render?
I have different errors in different sites (and I will fix them) but does it affect anything?
Here is an example:

The javascript errors most likely won't affect the server, since Javascript is executed on client side.
When it comes to page render, javascript errors might break your page. Let's get for example angular single application, if there is javascript error, you're most likely to see nothing at all.
Errors such as undefined is not a function might be sign for passing value instead of callback. For example:
$.ajax("url.php", 32); // the second parameter must be callback/function
You must review your code and fix them, because these errors are clear sign that something in your application is not working.

Related

Best way to remove unused javascript suggested by lighthouse. Is setTimeout a good idea? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
Lighthouse suggests that I need to remove the unused javascript from the third party javascript library say index.js . It is okay for this particular library to load after few 10 seconds once the page is loaded. So I used the SetTimeout method to do that but I don't think that is the right approach to do it.
Once I do that, lighthouse does not complain about unused javascript from this library and improves the score, but I am worried that in production Google measure the overall performance of the page from the moment page loads to the moment user leaves the page. So in that sense, the unused javascript is never removed and just delayed for the execution. People also suggested that lazy loading JS on user events will help but in our the case mentioned above, the JS should load automatically.
I am basically looking for the suggestion to:
How to handle the JS libraries that I can't get rid of and which has lot of unused code in the page?
Is setTimeout good solution for the above case?
Is my understanding of performance calculation by Google correct (in production environment) although it does not show unused JS after delaying for 10seconds?
I would be more than happy to get the answers.

prevent bots / scrapers executing javascript to get output [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I see allot about Cpatcha's and Submission forms / methods to block bots and content scrapers / leechers but nothing about blocking those who take the entire JavaScript contents and execute it to obtain and view what it is outputting.
Is it possible to prevent bots executing JavaScript to obtain the output.
I have looked at if statements within JavaScipt checking screen resolutions, keyboards, mouse, touch screens basic human required functions etc but it is a hard area to find information on.
if (bot){ //don't execute Javascript don't let the bot get the real output.
return;
}
The only known mechanism is to use minification and obfuscation of your javacsript functions. Change them on every deploy or every day through a script process. Another thing is not to have window methods on the global space.
You may want to look at Web Assembly, but not all browsers have currently adopted it.
There is no straight forward way to achieve this perfectly. If people put enough time they can crack it out.

How do I validate HTML with Javascript? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I would like to verify that a string is valid HTML, like the W3C Service does. I specifically don't want any browser corrections (like closing open tags), which precludes options that create DOM elements and read the HTML from them. It will run very frequently, so I really need to run it locally. Libraries are OK, jQuery is OK.
Edit #1: I'm asking about HTML validation, not form or input validation.
Edit #2: What I need is basically a Javascript implementation of the Nu HTML Checker.
Provided you're running node.js or python on the server side you can use a library like html5-lint by Mozilla to do all the heavy lifting for you. And for the java world there is a similar library jtidy and there are countless of similar libraries out there.

AJAX Microgames [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
If you're not familiar with the concept of a Microgame, check out this video of WarioWare Twisted.
I'm interested in setting up a site where users can play series of browser-based Microgames which are delivered to them by a server. Ideally this would allow me to crowdsource the games and have an open submission system. What sort of scheme could I use to make this work?
I'm thinking that one way to do it would be to have each game consist of:
A javascript file that defines a MicroGame object that controls a rectangular portion of the screen, gets input and timing information from the main page, then calls back to the main page with a "Success" or "Failure" message.
A folder of assets that must be downloaded before the game executes.
Is this possible to do, client-side within a browser? Where would be a good place to start figuring this out?
There are a lot of open issues here. The biggest problem is what language do they submit games in which you can execute safely on the players machines? That said, there are tools like this out there. You could look at the excellent Play My Code for inspiration.

If I use twice a $.get() function with the same page will it load it twice? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm creating two codes that works with the same page with two AJAX load in each code. Question is, I did both scripts separated and now I'm asking myself it this will make the browser will load twice the same page or it's smart and it will load the page once.
Thanks.
Of course. Calling $.get twice issues two AJAX requests. However the browser may get the response from a local cache depending on the server side (i.e. caching strategy set in HTTP headers). Assuming that that's what you are concerned about. But success handlers will still fire for each request.

Categories