Solved

Loading Multiple TinyMCE instances is freezing the browser

Posted on 2011-09-20
7
992 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
Hi ray-solomon, any idea how I could load each tinymce instances in a 5 seconds interval?
0
 

Author Comment

by:Bandai2
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

11 Experts available now in Live!

Get 1:1 Help Now