Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá! Tava dando uma olhada no código fonte da página inicial do Facebook (aquela em que se faz o login) e me deparei com isso:
<script>(require("ServerJSDefine")).handleDefines([["URLFragmentPreludeConfig",[],{"incorporateQuicklingFragment":true,"hashtagRedirect":true},137],["BootloaderConfig",[],{},329],["CSSLoaderConfig",[],{"timeout":5000},619],["CurrentUserInitialData",[],{"USER_ID":"0","ACCOUNT_ID":"0"},270],["SiteData",[],{"revision":1548948,"tier":"","push_phase":"V3","pkg_cohort":"EXP1:DEFAULT","vip":"31.13.73.1"},317],["UserAgentData",[],{"browserArchitecture":"32","browserFullVersion":"39.0.2171.95","browserMinorVersion":0,"browserName":"Chrome","browserVersion":39,"deviceName":"Unknown","engineName":"WebKit","engineVersion":"537.36","platformArchitecture":"32","platformName":"Mac OS X","platformVersion":"10.7","platformFullVersion":"10.7.5"},527],["CurrentCommunityInitialData",[],{},490],["DTSGInitialData",[],{},258],["ISB",[],{},330],["LSD",[],{"token":"AVokTzZh"},323],["BanzaiConfig",[],{"EXPIRY":86400000,"MAX_SIZE":10000,"MAX_WAIT":150000,"RESTORE_WAIT":150000,"blacklist":["time_spent"],"gks":{"adapterhooks":true,"boosted_pagelikes":true,"boosted_posts":true,"boosted_website":true,"jslogger":true,"mercury_send_error_logging":true,"miny_compression":true,"pages_client_logging":true,"time_spent_bit_array":true,"time_spent_debug":true,"useraction":true,"videos":true,"visibility_tracking":true,"vitals":true,"allow_userid_mismatch":true}},7],["AsyncRequestConfig",[],{"retryOnNetworkError":"1"},328],["FbtLogger",[],{"logger":null},288],["FbtQTOverrides",[],{"overrides":{"1_f6f32d47f40ef878e082b3231d06b2d4":"Problemas ao se conectar?","1_4f9484aa4d960982e51037873dbfac75":"Problemas ao se conectar?"}},551],["EagleEyeConfig",[],{"seed":"0Cz1","sessionStorage":1},294],["TrackingConfig",[],{"domain":"https:\/\/pixel.facebook.com"},325],["ErrorSignalConfig",[],{"uri":"https:\/\/error.facebook.com\/common\/scribe_endpoint.php"},319],["InitialServerTime",[],{"serverTime":1420236565000},204],["UFIConstants",[],{"UFIActionType":{"COMMENT_LIKE":"fa-type:comment-like","COMMENT_SET_SPAM":"fa-type:mark-spam","DELETE_COMMENT":"fa-type:delete-comment","DISABLE_COMMENTS":"fa-type:disable-comments","LIVE_DELETE_COMMENT":"fa-type:live-delete-comment","LIKE_ACTION":"fa-type:like","SUBSCRIBE_ACTION":"fa-type:subscribe","REMOVE_PREVIEW":"fa-type:remove-preview","MARK_COMMENT_SPAM":"fa-type:mark-spam","CONFIRM_COMMENT_REMOVAL":"fa-type:confirm-remove","TRANSLATE_COMMENT":"fa-type:translate-comment","COMMENT_LIKECOUNT_UPDATE":"fa-type:comment-likecount-update","ADD_COMMENT_ACTION":"fa-type:add-comment"},"UFICommentOrderingMode":{"CHRONOLOGICAL":"chronological","RANKED_THREADED":"ranked_threaded","TOPLEVEL":"toplevel","RECENT_ACTIVITY":"recent_activity","FEATURED":"featured","UNSUPPORTED":"unsupported"},"UFIFeedbackSourceType":{"PROFILE":0,"NEWS_FEED":1,"OBJECT":2,"MOBILE":3,"EMAIL":4,"PROFILE_APPROVAL":10,"TICKER":12,"NONE":13,"INTERN":14,"ADS":15,"EVENT_GOING_FLYOUT":16,"PHOTOS_SNOWLIFT":17,"NOTIFICATION_FLYOUT":18,"PHOTOS_SNOWFLAKE":20},"UFIPayloadSourceType":{"UNKNOWN":0,"INITIAL_SERVER":1,"LIVE_SEND":2,"USER_ACTION":3,"ENDPOINT_LIKE":10,"ENDPOINT_COMMENT_LIKE":11,"ENDPOINT_ADD_COMMENT":12,"ENDPOINT_EDIT_COMMENT":13,"ENDPOINT_DELETE_COMMENT":14,"ENDPOINT_COMMENT_SPAM":16,"ENDPOINT_REMOVE_PREVIEW":17,"ENDPOINT_ID_COMMENT_FETCH":18,"ENDPOINT_COMMENT_FETCH":19,"ENDPOINT_TRANSLATE_COMMENT":20,"ENDPOINT_BAN":21,"ENDPOINT_SUBSCRIBE":22,"ENDPOINT_COMMENT_LIKECOUNT_UPDATE":23,"ENDPOINT_DISABLE_COMMENTS":24,"ENDPOINT_ACTOR_CHANGE":25},"UFIStatus":{"DELETED":"status:deleted","SPAM":"status:spam","SPAM_DISPLAY":"status:spam-display","LIVE_DELETED":"status:live-deleted","FAILED_ADD":"status:failed-add","FAILED_EDIT":"status:failed-edit","PENDING_EDIT":"status:pending-edit"},"attachmentTruncationLength":80,"commentTruncationLength":420,"commentTruncationMaxLines":3,"commentTruncationPercent":0.6,"commentURLTruncationLength":60,"defaultPageSize":50,"infiniteScrollRangeForQANDAPermalinks":1000,"minCommentsForOrderingModeSelector":2,"unavailableCommentKey":"unavailable_comment_key"},240]]);new (require("ServerJS"))().handle({"require":[["markJSEnabled"],["lowerDomain"],["URLFragmentPrelude"],["Primer"],["Bootloader"]]});</script>
Queria entender pra que serve esses scripts. Alguém pode me dizer?
MUITO OßRIGAD0
Olá.
Esses scripts são "minificados".
Na verdade, não são escritos assim no momento de desenvolver a funcionalidade da página. São escritos da forma correta, que é usando indentação e nomenclatura que facilitem a leitura e a compreensão. Antes de serem incluídos no ambiente de produção (que é o que realmente entra em contato com os clientes), passam por esse processo de "minificação".
A principal justificativa pra isso é reduzir o tamanho dos arquivos. Isso é feito excluindo espaços desnecessários e, às vezes, renomeando variáveis de forma consistente, trocando nomes longos por nomes curtos.
Pode parecer besteira, mas economizar algumas centenas de bytes em determinados arquivos gera economia de infraestrutura significativa quando eles são acessados milhões de vezes.