Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
98 views
in Technique[技术] by (71.8m points)

javascript - Performance: jQuery load function vs rendering HTML from zero using jQuery

I'm creating a chrome extension to make a time schedule table.

I have two HTML pages:

  • popup html page where where schedule appears
  • options html page where user can configure the schedule details (no. hours, time periods, days to show, etc..).

At the beginning, I was going to simply save all schedule settings as a json in local storage and dynamically render the table based on it using jQuery each time user checks the schedule..

// When user saves settings, store options to localStorage 
localStorage["preferences"] = JSON.stringify(preferences)

// then later use it to render the table using jQuery
savedPreferences = JSON.parse(localStorage["preferences"]);
$("ScheduleDiv").html("<table id="Schedule"></table>)
for (i = 0; i < savedPreferences.timePeriods ; i++){
$("#Schedule").insertRow(0) ...
// and so on

but then I thought, what if I just dynamically render the table into HTML file for one time, and then each time user opens the popup it will load the saved file:

jQuery $("#ScheduleDiv).load('SavedSchedule.html)

instead of creating the table from zero each time? 1- Is this possible for a chrome extension? 2- Is it better from a performance perspective to load an external file each time?

Thank you

question from:https://stackoverflow.com/questions/65649651/performance-jquery-load-function-vs-rendering-html-from-zero-using-jquery

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...