XmlHttpRequest or iframe to load a web application? - javascript

I have a little perfomance issue with a web application I am using and I would like to know how can I solve it.
You see, when I enter to my web application, everything starts loading and takes some time since the application make some requests to a database to retrieve some data. I would like to know if I can put an iframe on a blank page with the link to my application so it can start loading inside the iframe making the rest of the page work and not getting stuck.
I've tried adding a XmlHttpRequest on a blank page requesting the web application link but it onlys retrieves the first elements that loads instantly but stops there. It doesn't get all the elements loaded before the first moment since they have some delay to appear because of the database request the web application makes.
How you guys think that I can load my web application inside another page and while my web application loads, I can still use the rest of the other page without everything getting stuck?
I hope you guys could guide me a little bit. Thank you in advance!

I've solved this by adding an invisible iframe that loads the page I need on the background and on the front I retreive everything with my application. Once I finish, I just delete the iframe on the background and move to the next task.

Related

Serve page from cache on navigation back

Basically what I want is this: https://dev.to/videos
You can select an item -> new page with item loads -> you click on backward button -> the old page is loaded from cache
I want that the same search page shown to user on navigation back, without calling the async fetch method again.
A solution seems to be SPA? But that is an enormous overhead.
I know how to do this with SPA. I need way without SPA.
iPhone, Android and Safari have a backforward-cache enabled by default, so no problem there. Static pages also don't have any problems.
I don't need any excact JavaScript code. I just want to know how do other websites solve this problem? Is SPA the only way? Are there any "frameworks" to solve this problem?
If server allows the page to be cached, your browser won't send a request again before the page expires.
https://stackoverflow.com/a/36554152/14263615

Getting rendered HTML from a page loaded with clientside JavaScript?

I have a Chrome extension that used to run a background script that would call an API for a website using the users session or cookie.
It'd simply perform a get request and then pull various image URLs from the page using Cheerio.
The owners of the site though have now changed how the pages work. On load, they call a JSON API, and the source of the page uses JavaScript to render the page.
The issues I have now is that when I call a get request, it simply gets the page source, rather than the rendered HTML.
Does anyone know how I can get the rendered HTML? I'd rather not open a tab with the page in chrome, grab the data with a content script and then close it (automatically of course) as there are hundreds of pages to go through, and that's quite intensive on CPU resources

How to get the response time when open a dynamic web page by using python (Cannot use selenium)

right now I am working on one project "get the response time when open a dynamic web page by using python". The requirement is that I cannot use selenium.
The web page I open has lots of javascripts and AJAX calls. So right now I use ghost.py to load the whole page. However, ghost.py takes a long time to open this web page which is much longer than opening this page on some browsers. So do you guys have any ideas or suggestions for it?
Thank you!

How to test whether gif images like 'Loading' are working or not?

I coded my page such that a GIF image is displayed until the web page is completely loaded. Now I'd like to test it whether it is working correctly or not. For this I need to make my web page to load slowly!! But I am not having any idea to make the web page load slowly! What can I do for a web page to load slowly? Please help me!!
You could load it via a proxy. Most of the ones on public lists are incredibly slow.
Here you can find some: http://www.samair.ru/proxy/time-01.htm
Good luck.
Add some server-side delay into your page. I assume that you're using a standard hosting provider or using your computer as a localhost and in both cases you have some form of server-side scripting.
In PHP you can do it like this:
<?php
sleep(20); // 20 sec delay
?>
Add it in the end of page, when at least your GIF animation has already sent to the client.
I'm not really sure, but you might be able to do the same using Javascript's setTimeout also.
P.S. I know that the original post didn't mention server-side scripting at all, however I assume it's possible for him/her to achieve it.

Does preloading content from a page skew my google analytics stats?

I'd like to write myself a simple script that uses AJAX to load the content from each page on my main navbar into a hidden div on the current page.
This is just so that I can preload as much of my important content as possible and get it cached on the user's computer (hopefully) before they've finished with the current page and want to move on.
I'm concerned that doing a request for every page on the site, every time someone visits, will really ruin the validity of my google analytics stats.
How does AJAX interact with google analytics? Does it count as a "page visit"?
If you retrieve each page without running the embedded script, then the Google Analytics code would not be run and it should not count as a page view. I suggest not doing anything with the code after retrieving each page (i.e. not inserting the content into a hidden div).
If you want to ajaxify your site by removing pages and replacing them with ajax requests, then all you need to do on the GA side of things is call _trackPageView whenever a page view should be tracked.

Categories