Solved

Loading Multiple TinyMCE instances is freezing the browser

Posted on 2011-09-20
7
1,024 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 108

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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now