PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | js/minify.js +41 -76 4.5.4 → 4.7.0 View file →
@@ -322,28 +322,8 @@
322 322 $.unblockUI();
323 323 });
324 324 });
325 325
326 - // Handle js excludes
327 - $('#wpo_min_jsprocessed').on('click', '.exclude', function(e) {
328 - e.preventDefault();
329 - var el = $(this);
330 - var excluded_file = get_excluded_file(el);
331 - add_excluded_js_file(excluded_file);
332 - tab_need_saving('js');
333 - highlight_excluded_item(el);
334 - });
335 -
336 - // Handle css excludes
337 - $('#wpo_min_cssprocessed').on('click', '.exclude', function(e) {
338 - e.preventDefault();
339 - var el = $(this);
340 - var excluded_file = get_excluded_file(el);
341 - add_excluded_css_file(excluded_file);
342 - tab_need_saving('css');
343 - highlight_excluded_item(el);
344 - });
345 -
346 326 // Trigger combined meta.json file download
347 327 $('.wpo-minify-download-metas-button').on('click', function(e) {
348 328 e.preventDefault();
349 329 send_command('get_minify_meta_files', null, function(response) {
@@ -360,83 +340,68 @@
360 340 link.click();
361 341 })
362 342 });
363 343
364 - /**
365 - * Get excluded file url
366 - *
367 - * @param {HTMLElement} el
368 - *
369 - * @return {string}
370 - */
371 - function get_excluded_file(el) {
372 - return el.data('url');
373 - }
344 + // Handle js excludes
345 + $('#wpo_min_jsprocessed').on('click', '.exclude', function(e) {
346 + e.preventDefault();
347 + get_url_and_tab_saving($(this), '#exclude_js', 'js');
348 + });
374 349
375 - /**
376 - * Exclude js file
377 - *
378 - * @param {string} excluded_file File url
379 - */
380 - function add_excluded_js_file(excluded_file) {
381 - var $js_textarea = $('#exclude_js');
382 - var list_of_excluded_files = $js_textarea.val();
383 - list_of_excluded_files += excluded_file + '\n';
384 - $js_textarea.val(list_of_excluded_files);
385 - }
350 + // Handle css excludes
351 + $('#wpo_min_cssprocessed').on('click', '.exclude', function(e) {
352 + e.preventDefault();
353 + get_url_and_tab_saving($(this), '#exclude_css', 'css');
354 + });
386 355
387 - /**
388 - * Exclude css file
389 - *
390 - * @param {string} excluded_file File url
391 - */
392 - function add_excluded_css_file(excluded_file) {
393 - var $css_textarea = $('#exclude_css');
394 - var list_of_excluded_files = $css_textarea.val();
395 - list_of_excluded_files += excluded_file + '\n';
396 - $css_textarea.val(list_of_excluded_files);
397 - }
398 -
399 356 // Handle defer
400 357 $('#wpo_min_jsprocessed').on('click', '.defer', function(e) {
401 358 e.preventDefault();
402 - add_deferred_file($(this));
359 + get_url_and_tab_saving($(this), '#async_js', 'js');
403 360 });
404 361
405 362 // Handle async loading
406 363 $('#wpo_min_cssprocessed').on('click', '.async', function(e) {
407 364 e.preventDefault();
408 - add_async_file($(this));
365 + get_url_and_tab_saving($(this), '#async_css', 'css');
409 366 });
410 -
367 +
411 368 /**
412 - * Add deferred file
369 + * Get url from an element and then save it
413 370 *
414 - * @param {HTMLElement} el target element
371 + * @param {HTMLElement} el
372 + * @param {string} target_el_id
373 + * @param {string} tab_name
374 + *
375 + * @return void
415 376 */
416 - function add_deferred_file(el) {
417 - var deferred_file = el.data('url');
418 - var $async_js_textarea = $('#async_js');
419 - var list_of_deferred_files = $async_js_textarea.val();
420 - list_of_deferred_files += deferred_file + '\n';
421 - $async_js_textarea.val(list_of_deferred_files);
422 - tab_need_saving('js');
377 + function get_url_and_tab_saving(el, target_el_id, tab_name) {
378 + var file_url = el.data('url');
379 + if ('' === file_url || undefined === file_url) {
380 + return;
381 + }
382 +
383 + add_url_to_next_line(target_el_id, file_url);
384 + tab_need_saving(tab_name);
423 385 highlight_excluded_item(el);
424 386 }
425 -
387 +
426 388 /**
427 - * Add asynchronously loading file
389 + * Add url to the next line of the element textarea
428 390 *
429 - * @param {HTMLElement} el target element
391 + * @param {string} target_el_id
392 + * @param {string} file_url
393 + *
394 + * @return void
430 395 */
431 - function add_async_file(el) {
432 - var async_file = el.data('url');
433 - var $async_css_textarea = $('#async_css');
434 - var list_of_async_files = $async_css_textarea.val();
435 - list_of_async_files += async_file + '\n';
436 - $async_css_textarea.val(list_of_async_files);
437 - tab_need_saving('css');
438 - highlight_excluded_item(el);
396 + function add_url_to_next_line(target_el_id, file_url) {
397 + var $textarea = $(target_el_id);
398 + var list_of_files = $textarea.val().trim();
399 + if ('' !== list_of_files) {
400 + list_of_files += '\n';
401 + }
402 + list_of_files += file_url;
403 + $textarea.val(list_of_files);
439 404 }
440 405
441 406 /**
442 407 *