Solved

Loading Multiple TinyMCE instances is freezing the browser

Posted on 2011-09-20
7
1,092 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 110

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 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