1👍
If you use Django’s {% include %}
tag, the template is constructed by the server and displayed in the browser after the construction is complete. On the other side, if you use jQuery.load()
, the requested template is included on the client-side using an AJAX request after the base template has finished loading.
In both cases, the displayed result in the browser should be the same. The advantage of jQuery’s method is that you can load the template later on, for example when you click a button on the page, without the need to reload the entire page in the browser. So you can handle user interaction in a more interactive way. An advantage of server-side method is that the entire DOM and content resides in the HTML file and can therefore be indexed by search engines if that should matter to you. HTML included by client-side JavaScript is not visible for search engines.
Generally speaking, if you just want to include HTML once a requested webpage gets loaded, use the server-side method using the include
tag. It’s more user-friendly and efficient to let the server do the template handling, especially if the templates are very large.
0👍
The ssi
or include
tags are included on server side (in this case by django). jQuery includes client based.
- [Answer]-Django admin panel interface missing
- [Answer]-Tastypie + Password reset
- [Answer]-How to set name in SelectDateWidget on buttons for month, year and day?
- [Answer]-How to avoid cleaned_data for each field if I have too many fields in the form
- [Answer]-How to track login locations of admin/staff in django website