If you have to write code for Internet Explorer make sure you chose an implementation, which uses array joins. Concatenating strings with the +
or +=
operator are extremely slow on IE. This is especially true for IE6. On modern browsers +=
is usually just as fast as array joins.
When I have to do lots of string concatenations I usually fill an array and don’t use a string builder class:
var html = []; html.push( "<html>", "<body>", "bla bla bla", "</body>", "</html>" ); return html.join("");
Note that the push
methods accepts multiple arguments.
Related Posts:
- How to fix “Cannot read property ‘addEventListener’ of null” error [duplicate]
- What does [object Object] mean?
- Remove class using jQuery
- How do I check whether a checkbox is checked in jQuery?
- Babel 7 – ReferenceError: regeneratorRuntime is not defined
- How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
- How can I check for “undefined” in JavaScript?
- How to make history.back() without getting a warning on the browser to reload the page?
- Split string into array
- convert Hsl to rgb and hex
- How to add jQuery code into HTML Page
- TypeError: Router.use() requires middleware function but got a Object
- What does jQuery.fn mean?
- “Uncaught TypeError: Cannot read property ‘style’ of null at.. “
- Difference between document.referrer and window.parent.location.href
- JavaScript replace/regex
- how to render a react component using ReactDOM Render
- How can I determine if a variable is ‘undefined’ or ‘null’?
- Cannot find module ‘@angular-devkit/core’
- iFrame onload JavaScript event
- What is the difference between state and props in React?
- Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters
- OnChange event using React JS for drop down
- how to get the last character of a string?
- Set timeout for ajax (jQuery)
- Escaping Discord subset of markdown
- ESLint Parsing error: Unexpected token
- Angular ForEach in Angular4/Typescript?
- How to convert JSON object to JavaScript array?
- How can I display a JavaScript object?
- JSLint says “missing radix parameter”
- How to handle ETIMEDOUT error?
- bootstrap-datetimepicker for bootstrap 4
- Proper way to wait for one function to finish before continuing?
- How do I check whether an array contains a string in TypeScript?
- alert a variable value
- How to check a radio button with jQuery?
- Get current URL with jQuery?
- How to get JSON from URL in JavaScript?
- How do you put an image file in a json object?
- How can I add a class to a DOM element in JavaScript?
- Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode
- Module not found: Error: Can’t resolve ‘fs’ in
- TypeError: $(…).modal is not a function with bootstrap Modal
- How to do fade-in and fade-out with JavaScript and CSS
- I want to remove double quotes from a String
- Calculating median – javascript
- Vue is not defined
- How to close current tab in a browser window?
- npm WARN enoent ENOENT: no such file or directory, open ‘C:\Users\Nuwanst\package.json’
- How to change value of object which is inside an array using JavaScript or jQuery?
- How to detect pressing Enter on keyboard using jQuery?
- How to make your Discord Bot always active
- How to write inside a DIV box with javascript
- How to make an HTML back link?
- How to fix getImageData() error The canvas has been tainted by cross-origin data?
- How to make fadeOut effect with pure JavaScript
- How to reload/refresh jQuery dataTable?
- How to enable a disabled checkbox dynamically?
- “Cross origin requests are only supported for HTTP.” error when loading a local file
- What is ‘xmlhttp.setRequestHeader();’ and in which situations is it used?
- Write / add data in JSON file using Node.js
- Set scroll position
- .filter is not a function
- What does wp-embed.min.js do in WordPress 4.4?
- Gutenberg – remove / add blocks with custom script
- Gutenberg extend blocks add new class name
- How do I add custom attributes to javascript tags in WordPress?
- Rest API authentication issue when called from fetch request in bundle.js
- Listbox return wrong value in WordPress 3.9
- Logout user and delete cookies from the client side?
- Strange gibberish JavaScript in Editor – site hacked?
- wp_enqueue_script & constants?
- Resolving Javascript errors likely related to Gantry framework
- WordPress customizer get control
- How to load JS for specific screen size using wp_enqueue_script?
- I am trying to add current logged in user to my zoho chat
- Where to upload JavaScript file in WordPress
- Conditional save return on Gutenberg Block
- Can I alter the block editor’s paste text behavior?
- Custom Block – save.js function not saving attributes
- Headless wp with react. How to handle routes?
- Where to paste Google Map Snippet / JavaScript / CSS for WordPress integration
- Issues trying to get an element by id
- How do I know if I should enqueue JS code or just include it in ONE PHP function?
- Setting Variable Path to Template Directory inside Script
- How can I integrate yepnope.js with WordPress (and plugins)?
- Dynamically add Js
- How to set javascript options for select2 in PHP array of plugin
- Change background video when scrolling reaches a certain ID
- Contact Form 7 Conditional redirect
- Immediate (e.g. without DOMContentLoaded) JS not working
- Dynamically changing logo on scroll function [closed]
- Script not working in post content
- Remove WordPress default registration client side validation?
- How could I add load more posts to my theme? [closed]
- Live Time on WP showing weirdly [closed]
- Javascript button to call custom fields data
- Table block variation with header section activated