Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loading Multiple TinyMCE instances is freezing the browser

Posted on 2011-09-20
7
Medium Priority
?
1,168 Views
Last Modified: 2012-05-12
I have a page with multiple tinymce instances running at the same time and it's freezing the browser whenever it loads. It's taking not less than 15 seconds of waiting before I could use the browser again. I've tested this on IE9, FF6, and Chrome and all of them are freezing for some time while it is loading.

How could I prevent this freezing from happening? I have at least 10 textarea with tinymce attached to it. Computer is running on core2duo with 4GB of RAM without any other program running, but this shouldn't matter as its supposed to work even with a lower spec PC.
0
Comment
Question by:Bandai2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 10

Expert Comment

by:ray-solomon
ID: 36567371
Some questions.

1) have you viewed it from a different computer/internet connection?

2) are you using TinyMCE compressor? - see the faq

3) Have you considered allowing only one instance to load by default instead of all 10? e.g. The user can press a button to instantiate more editors where applicable.


0
 

Author Comment

by:Bandai2
ID: 36567448
1) Yes I tried it using a different computer (an older one) and the freeze time is longer.

2) I'm checking out the TinyMCE compressor now, but I don't think this would stop the freezing at all.

3) You mean the "Load on demand"? I don't think that's a good idea, think about how that would impact you if you need to click a button first every time you want to input something to every field. What a hassle.
0
 
LVL 10

Expert Comment

by:ray-solomon
ID: 36570715
Another way is to activate each editor in 5 seconds intervals or so. The page should load faster this way.

Have you tried using less theme options in your configuration? - e.g. A Full featured editor will load slower than a slimmed down version.
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36595438
I've never had success using more than one instance of TinyMCE on the same page, so don't feel bad if it doesn't work out for you.  I like the idea that ray-solomon suggested about having the user press a button to instantiate more editors.  I think I might want to put more editors on more pages - with one per page.
0
 

Author Comment

by:Bandai2
ID: 36598554
Hi ray-solomon, any idea how I could load each tinymce instances in a 5 seconds interval?
0
 

Author Comment

by:Bandai2
ID: 36598605
Just an update, implemented the compressor as well but it is still freezing for some time before loading.
0
 
LVL 10

Accepted Solution

by:
ray-solomon earned 2000 total points
ID: 36708398
No problem. Sorry for the late response. Its my birthday today and I am busy doing other things.

here is the example you requested:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">

tinyMCE.init({
	editor_selector : "mceEditor",
	theme : "advanced",
	plugins : "advimage,advlink,contextmenu,paste,advhr",
	theme_advanced_buttons1 : "fontselect,fontsizeselect, forecolor,backcolor",
	theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,undo,redo",
	theme_advanced_buttons3 : "hr,removeformat,visualaid,charmap,cut,copy,paste,pastetext,pasteword,link,unlink,image,separator,code",
	theme_advanced_toolbar_location : "bottom",
	theme_advanced_toolbar_align : "left",
	theme_advanced_disable : "styleselect",
	apply_source_formatting : false,
	mode : "exact",
	width : "614px",
	elements : "t0",
	cleanup_on_startup : true,
	verify_html : true,
	cleanup : true,
	preformatted : false,
	forced_root_block : false,
	force_br_newlines : false,
	force_p_newlines : true,
	theme_advanced_source_editor_wrap : true,
	//convert_urls : true,
	remove_script_host : true,
	relative_urls : false,
	visual : false,
	setup : function(ed) {
		ed.onInit.add(function(ed) {
			setTimeout(function() { 
				var x = 0;
				(function loop(i) {
					if (i < editorIDs.length) {
						createEditor(editorIDs[i]);
						setTimeout(function() { loop(++i); }, 5000);
					}
				})(x);
			}, 5000);
		});
	}
});

/* Predefine IDs for textareas that will be created */
var editorIDs = new Array('t1', 't2', 't3', 't4', 't5');

function createEditor(id) {
	
	var textarea = document.createElement('textarea');
	textarea.id = id;
	textarea.cols = '45';
	textarea.rows = '5';
	document.body.appendChild(textarea);
	var new_editor = new tinymce.Editor(id, {});
	new_editor.render();
}
</script>
<style type="text/css">
textarea {
	-moz-border-radius: 0px;
	-webkit-border-radius: 0px;
	background-color: #FFF;
	width: 594px;
	height: 300px;
}
</style>
</head>

<body>
<textarea name="t0" id="t0" cols="45" rows="5"></textarea>
</body>
</html>

Open in new window

0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question