001// Copyright 2010 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007// http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry5.services.javascript;
016
017/**
018 * Sets the priority for JavaScript initialization scripting. InitializationPriority allows coarse-grained control
019 * over the order in which initialization occurs on the client. The default is normally {@link #NORMAL}. Starting in 5.4,
020 * these values have less meaning, as the {@linkplain JavaScriptSupport#require(String) dynamic loading of modules} may
021 * have unexpected effects on the exact order in which initialization occurs as some initializations may be deferred until
022 * a referenced module, or a dependency of a referenced module, has been loaded.
023 *
024 * @since 5.2.0
025 */
026public enum InitializationPriority
027{
028    /**
029     * Provided JavaScript will be executed immediately (it is not deferred until the page loads). Execution occur via
030     * JavaScript's {@code eval}, and occurs once all {@linkplain JavaScriptSupport#importJavaScriptLibrary(org.apache.tapestry5.Asset) JavaScript libraries}
031     * (but not modules) for the page have been loaded.
032     * <p/>
033     *
034     * @deprecated Deprecated in 5.4; this is now treated as "earlier than {@linkplain #EARLY early}".
035     */
036    IMMEDIATE,
037
038    /**
039     * All early execution occurs before {@link #NORMAL}.
040     */
041    EARLY,
042
043    /**
044     * This is the typical priority.
045     */
046    NORMAL,
047
048    /**
049     * Execution occurs after {@link #NORMAL}.
050     */
051    LATE
052}