The phase difference φ across a Josephson junction is considered for a film with a thickness d ≪ λ, where λ is the London penetration depth in the superconducting banks. Special attention is given to the case of a critical current density jc varying along the junction. It is shown that a nonlinear integro-differential equation determines the spatial distribution of φ for d ≪ λ. Josephson properties of grain boundaries in thin-YBCO films are treated for the case of jc alternating along these boundaries. It is shown that if the typical amplitude of alternations of jc is high compared to the average value of jc, then a spontaneous flux and two types of fractional Josephson vortices can be observed. The fractional Josephson vortices keep magnetic fluxes (φ1 and φ2, where (φ1 + φ2 = φ0, φ0 is flux quantum, and φ1 < φ0/2, φ2 > φ0/2. We demonstrate that these fractional vortices can be observed in thin-YBCO films under conditions of appearance of the spontaneous magnetic flux. A method is proposed to extract the fractional vortices from the experimental flux patterns. Propagation of an electromagnetic wave along a grain boundary with an alternating critical current density is treated as an example of an application of the integro-differential equation for the phase difference φ.