I want to load in a page a div from an another internal page.
The div that i want to display is a cart.
I want to show the cart from my shopping website in the header of my blog.
I can use PHP Dom parser or Jquery load.
Which solution is the best (performance, speed to display the content)?
If you’re concerned about speed, reduce the number of remote calls you have in your application. I write this especially because of this sentence in your question:
You should not do a remote call here to obtain the scripts output but instead – as long as it’s your code generating that internal page – invoke the code instead directly that generates the HTML.
Example:
div, as it’s a framework you might be able to create a route for that.the_basketthat is outputting that chunk of HTML.Next to that display performance in a browser is always best, when you provide all HTML before displaying. That is, if the
<div>is already part of the page when the browser downloads it from the server. That’s also best network performance as there is no additional request as with ajax.This method even tops ajax in any case if javascript is disabled or not working.