Adlago Posted March 30, 2019 Posted March 30, 2019 I'm launching this topic with the idea, team developer to consider this resource. What do I mean: - This is a secondary resource - it is used in certain cases. - This resource provides between 400 and 600 milliseconds delay in the loading site, meaning loading this resource from a browser starts with a delay that is caused by the logic you have entered in the processing of notifications. - This resource is not required for guest visitors. @Rikki - yes, sound in logged user is preload * Author: Rikki Tissier */ ;( function($, _, undefined){ "use strict"; ips.createModule('ips.utils.notification', function () { var supported = ( "Notification" in window ); var sound = null; // Preload our notification sound if( !ips.getSetting('disableNotificationSounds') ){ sound = new Howl({ src: ips.getSetting('baseURL') + 'applications/core/interface/sounds/notification.mp3', autoplay: false }); } but, when a logged user receives a notification... For Guests this resource is useless. Even harmful if you look at a place to load time. This resource at initial loading site extends DOM loaded to CSS and JS (h2 protocol) by approximately 400-600 milliseconds. Analysis of sites publishing ads valuing ads is done by bot machines that evaluate as Guests ... This delay causes a loss of money for your clients using the IPS Suite and publishing ads. In my analysis, the process of loading a notification.mp3 is initialized by howler.core.mine.js , after which this sound request is retrieved from a root_framework.js and after permissions analysis, and I still do not know what is hard to determine how many more checks are allowed on a browser to load this little size of mp3. There is something stupid - with an excuse for the phrase, in this decision for this mp3. Please reconsider it and find a better solution to help, not to make a delay. I'm not sure, but maybe it's good to load it after time 'onload', it makes no sense that it could slow DOM loaded time.
Adlago Posted April 22, 2019 Author Posted April 22, 2019 What I can not understand - please comment. notification.mp3 is initiated by the howler.core.min.js, loading is a task of the framework.js. That's good, but why does the start notification.mp3 download request lag behind by more than 600 milliseconds from the end downloading framework.js? If this process does not speed up, then what is the best way to get this resource "preload"?
Joy Rex Posted April 22, 2019 Posted April 22, 2019 If I am understanding correctly, this is the notification IPS uses if a user allows browser notifications? If that's the case, then it would only affect users who allowed notifications from your site, correct (registered users or otherwise)?
Adlago Posted April 22, 2019 Author Posted April 22, 2019 3 minutes ago, Joy Rex said: If I am understanding correctly, this is the notification IPS uses if a user allows browser notifications? If that's the case, then it would only affect users who allowed notifications from your site, correct (registered users or otherwise)? It should be so - but this mp3 is being loaded by every guest and this is a slow loading site. So I'm looking for a solution.
Joy Rex Posted April 22, 2019 Posted April 22, 2019 So the MP3 is loading regardless of whether the user enables browser notifications? That's not very efficient, but it may be the only way to allow users to enable notifications or not... I'm assuming the MP3 itself is small - if not, you could potentially find the file on the server and reduce the size of it further without compromising the sound quality using an online compression utility.
Adlago Posted April 22, 2019 Author Posted April 22, 2019 13 minutes ago, Joy Rex said: So the MP3 is loading regardless of whether the user enables browser notifications? That's not very efficient, but it may be the only way to allow users to enable notifications or not... I'm assuming the MP3 itself is small - if not, you could potentially find the file on the server and reduce the size of it further without compromising the sound quality using an online compression utility. The file is small. But the whole possible action of this notification is a complicated process and calculation from a browser delayed loading site. IPS needs to find another solution. Here, look at the entire code that a browser needs to process before downloading m3 ... (function($,_,undefined){"use strict";ips.createModule('ips.utils.notification',function(){var supported=("Notification"in window);var sound=null;if(!ips.getSetting('disableNotificationSounds')){sound=new Howl({src:ips.getSetting('baseURL')+'applications/core/interface/sounds/notification.mp3',autoplay:false});} var hasPermission=function(){if(!supported||Notification.permission=='denied'||Notification.permission=='default'){return false;} return true;},needsPermission=function(){if(supported&&Notification.permission=='default'){return true;} return false;},permissionLevel=function(){if(!supported){return null;} return Notification.permission;},requestPermission=function(){if(supported){Notification.requestPermission(function(result){if(result=='granted'){$(document).trigger('permissionGranted.notifications');}else{$(document).trigger('permissionDenied.notifications');}});}},create=function(options){return new notification(options);},playSound=function(){try{if(!ips.getSetting('disableNotificationSounds')){sound.play();}}catch(err){}};function notification(options){this._notification=null;this._options=_.defaults(options,{title:'',body:'',icon:'',timeout:false,tag:'',dir:$('html').attr('dir')||'ltr',lang:$('html').attr('lang')||'',onShow:$.noop,onHide:$.noop,onClick:$.noop,onError:$.noop});this._options.body=_.unescape(this._options.body.replace(/'/g,"'").replace(/<[^>]*>?/g,''));this._options.title=_.unescape(this._options.title.replace(/'/g,"'"));this.show=function(){this._notification=new Notification(this._options.title,this._options);this._notification.addEventListener('show',this._options.onShow,false);this._notification.addEventListener('hide',this._options.onHide,false);this._notification.addEventListener('click',this._options.onClick,false);this._notification.addEventListener('error',this._options.onError,false);if(this._options.timeout!==false){setTimeout(_.bind(this.hide,this),this._options.timeout*1000);}};this.hide=function(){this._notification.close();this._notification.removeEventListener('show',this._options.onShow,false);this._notification.removeEventListener('hide',this._options.onHide,false);this._notification.removeEventListener('click',this._options.onClick,false);this._notification.removeEventListener('error',this._options.onError,false);};};return{supported:supported,hasPermission:hasPermission,needsPermission:needsPermission,permissionLevel:permissionLevel,requestPermission:requestPermission,create:create,playSound:playSound};});}(jQuery,_)); These are 600 milliseconds that delay any site, not just mine.
Rikki Posted April 22, 2019 Posted April 22, 2019 I've submitted a change for 4.4.4 that will disable preloading of this sound file (meaning, it'll just load on demand when it's needed, rather than on page load).
Recommended Posts
Archived
This topic is now archived and is closed to further replies.